<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

</head>

<body>
    <div id="app-7">
        <ol>
            <todo-item
            v-for="item in groceryList"
            v-bind:todo="item"
            v-bind:key="item.id"
            ></todo-item>
        </ol>
    </div>

    <script>
        Vue.component('todo-item',{
            props:['todo'],
            template:'<li>{{todo.text}}</li>'
        })
        var app7 = new Vue({
            
            el: "#app-7",
            data: {
                groceryList:[
                {id:0,text:'蔬菜'},
                {id:1,text:'奶酪'},
                {id:2,text:'随便其他什么人吃的东西'},
                ]
            },
        })
    </script>
    <!-- <div id="app-6">
        <p>{{message}}</p>
        <input v-model="message">
    </div>

    <script>
        var app6 = new Vue({
            el: "#app-6",
            data: {
                message: "Hello Vue.js!",
            },
        })
    </script> -->
    <!-- <div id="app-5">
        <p>{{message}}</p>
        <button v-on:click="reverseMessage">翻转消息</button>
    </div>

    <script>
        var app5 = new Vue({
            el: "#app-5",
            data: {
                message: "Hello Vue.js",
            },
            method: {
                reverseMessage: function () {
                    this.message = this.message.split('').reverse().join('')
                }
            }
        })
    </script> -->
</body>

</html>